package test1230pm;

public class ChangFangXing implements Tu {

    int chang;

    int kuan;

    public ChangFangXing() {
    }

    public ChangFangXing(int chang, int kuan) {
        this.chang = chang;
        this.kuan = kuan;
    }

    public int getChang() {
        return chang;
    }

    public void setChang(int chang) {
        this.chang = chang;
    }

    public int getKuan() {
        return kuan;
    }

    public void setKuan(int kuan) {
        this.kuan = kuan;
    }

    @Override
    public String toString() {
        return "ChangFangXing{" +
                "chang=" + chang +
                ", kuan=" + kuan +
                '}';
    }

    // 周长
    public int m1() {
        return (chang + kuan) * 2;
    }

    // 面积
    public int m2() {
        return chang * kuan;
    }

    public static void main(String[] args) {

        ChangFangXing a = new ChangFangXing();
        a.setChang(5);
        a.setKuan(2);
        int x = a.m1();
        System.out.println(x);
        int y = a.m2();
        System.out.println(y);

        ChangFangXing b = new ChangFangXing(7, 2);
        System.out.println(b.m1());
        System.out.println(b.m2());

    }

}
